<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <title>角色修改页面</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css">
</head>
<body>
<%--layui-form layui的表单样式--%>
<form class="layui-form">
    <input type="hidden" value="${role.id}" name="id"/>
    <div class="layui-form-item">
        <label class="layui-form-label">角色名</label>
        <div class="layui-input-inline">
            <input type="text" name="rolename"  value="${role.rolename}" required  lay-verify="required" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-inline">
            <input type="radio" name="status" value="1" <c:if test="${role.status=='1'}">checked</c:if> title="正常">
            <input type="radio" name="status" value="0" <c:if test="${role.status=='0'}">checked</c:if> title="注销">
        </div>
    </div>
    <%--操作人信息应从session中互殴当前用户登录信息，现手动输入，后期再修改--%>
    <div class="layui-form-item">
        <label class="layui-form-label">操作人</label>
        <div class="layui-input-inline">
            <input type="text" name="operator" value="${sessionScope.admin.id}" required  lay-verify="number" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">描述</label>
        <div class="layui-input-inline">
            <textarea name="explain" class="layui-textarea">${role.explain}</textarea>
        </div>
    </div>
    <div class="layui-form-item" style="margin-left: 110px">
        <div class="layui-input-inline">
            <button class="layui-btn" lay-submit lay-filter="update">修改</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
<script>
    layui.use(['layer','form','jquery'],function () {
        //layui引入特定对象的方式
        var layer=layui.layer,//layer 弹窗对象
            form=layui.form;//表单对象
        var $=layui.$;
        layer.msg('Hello word');
        form.on("submit(update)",function (data) {
            $.post("${pageContext.request.contextPath}/role/update2",data.field,function (result) {
                if (result.code==0){
                    layer.msg("修改成功")
                    parent.layui.table.reload("test",{
                        page:{
                            curr:1
                        }
                    })
                    var index=parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                }
            },"json")
            return false;
        })
    });
</script>
</body>
</html>
